﻿using System;
using HigLabo.Net.Extensions;

namespace HigLabo.Net.WindowsLive
{
    /// <summary>
    /// 
    /// </summary>
    public class Application : ResponseObject
    {
        /// <summary>
        /// 
        /// </summary>
        public String ID { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public String Name { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public String ClientID { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public String ClientSecret { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public AppUriCollection Uris { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public String TermsOfServiceLink { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public String PrivacyLink { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public DateTimeOffset? CreatedTime { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public DateTimeOffset? UpdatedTime { get; set; }

       
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsontext"></param>
        public Application(String jsontext)
        {
            this.SetProperty(jsontext);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsontext"></param>
        public override void SetProperty(String jsontext)
        {
            var d = this.SetData(jsontext);
            this.ID = d.ToString("id");
            this.Name = d.ToString("name");
            this.ClientID = d.ToString("client_id");
            this.ClientSecret = d.ToString("client_secret");
            if (d.ContainsKey("uris"))
            {
                this.Uris = new AppUriCollection(d.ToString("uris"));
            }
            this.TermsOfServiceLink = d.ToString("terms_of_service_link");
            this.PrivacyLink = d.ToString("privacy_link");
            this.CreatedTime = d.ToDateTimeOffset("created_time");
            this.UpdatedTime = d.ToDateTimeOffset("updated_time");
        }
    }
}
